/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.application.Platform
 *  javafx.event.EventHandler
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Button
 *  javafx.scene.input.KeyCode
 *  javafx.scene.input.KeyEvent
 *  javafx.scene.layout.AnchorPane
 *  javafx.stage.Stage
 *  org.springframework.beans.factory.annotation.Autowired
 */
package com.gys.controller.salesReceipts;

import cn.hutool.core.util.ObjectUtil;
import com.gys.common.util.CommonUtil;
import com.gys.common.util.SpringUtil;
import com.gys.controller.BaseController;
import com.gys.controller.salesReceipts.SalesReceiptsMainController;
import com.gys.view.salesReceipts.ZysyLogOutView;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.Timer;
import java.util.TimerTask;
import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class ZysyLogOutController
extends BaseController
implements Initializable {
    @FXML
    private AnchorPane pane;
    @FXML
    private Button sureBtn;
    @Autowired
    private SalesReceiptsMainController salesReceiptsMainController;

    public void initialize(URL location, ResourceBundle resources) {
        CommonUtil.initIcon(ZysyLogOutView.class);
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.sureBtn)) {
            return;
        }
        this.sureBtn.requestFocus();
        new Timer().schedule(new TimerTask(){

            @Override
            public void run() {
                ZysyLogOutView view = SpringUtil.getBean(ZysyLogOutView.class);
                final Stage stage = (Stage)view.getView().getScene().getWindow();
                stage.getScene().setOnKeyReleased((EventHandler)new EventHandler<KeyEvent>(){

                    public void handle(KeyEvent e) {
                        if (e.getCode() == KeyCode.ENTER) {
                            ZysyLogOutController.this.sureAction();
                        } else if (e.getCode() == KeyCode.ESCAPE) {
                            ZysyLogOutController.this.cancelAction();
                        }
                        e.consume();
                    }
                });
                Platform.runLater((Runnable)new Runnable(){

                    @Override
                    public void run() {
                        stage.setTitle("\u4e2d\u836f\u6536\u94f6");
                    }
                });
            }
        }, 200L);
    }

    @FXML
    private void sureAction() {
        this.salesReceiptsMainController.getZysy().setVisible(false);
        this.cancelAction();
    }

    @FXML
    private void cancelAction() {
        this.pane.getScene().getWindow().hide();
    }
}

